<template>
  <div>
    <el-empty
      v-if="isShow"
      description="你还没有发布笔记哦"
      class="aaa"
    ></el-empty>
    <ul>
      <router-link :to="{ path: '/details', query: { i: i } }">
        <li v-for="item in myNote" :key="item.id" @click="click(item.id)">
          <img :src="item.url" alt="" />
          <div class="introduce">{{ item.content }}</div>
          <div class="information">
            <div class="photo">
              <img :src="item.head" alt="" />
              <div class="name">{{ item.name }}</div>
            </div>
            <div
              class="iconfont fabulous"
              :class="item.isLike == true ? 'active' : ''"
            >
              &#xe604;{{ item.fabulous }}
            </div>
          </div>
        </li>
      </router-link>
    </ul>
  </div>
</template>
<script>
import { mapState } from "vuex";
export default {
  data() {
    return {
      i: 0,
      isShow: true,
    };
  },
  computed: {
    ...mapState(["myNote"]),
  },
  methods: {
    click(i) {
      this.i = i - 1;
    },
  },
  mounted() {
    if (this.myNote.length > 0) {
      this.isShow = false;
    } else {
      this.isShow = true;
    }
  },
};
</script>

<style scoped lang="scss">
ul {
  padding: 10px 5px;
  box-sizing: border-box;
  a {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    li {
      margin: 2px 0;
      border-radius: 5px;
      flex-basis: 49.5%;
      height: 300px;
      display: flex;
      flex-direction: column;
      background: #fff;
      padding: 2px;
      box-sizing: border-box;
      box-shadow: 2px 2px 4px #ccc;
      > img {
        width: 100%;
        height: 220px;
      }
      .introduce {
        padding: 0 5px;
        box-sizing: border-box;
        width: 100%;
        height: 40px;
        font-size: 14px;
        line-height: 20px;
        display: -webkit-box;
        overflow: hidden;
        text-overflow: ellipsis;
        -webkit-box-orient: vertical;
        -webkit-line-clamp: 2;
      }
      .information {
        width: 100%;
        height: 40px;
        display: flex;
        justify-content: space-between;
        .photo {
          flex-basis: 60%;
          display: flex;
          > img {
            margin-top: 5px;
            width: 30px;
            height: 30px;
            border-radius: 50%;
          }
          .name {
            height: 40px;
            font-size: 14px;
            line-height: 40px;
          }
        }
        .fabulous {
          flex-basis: 40%;
          font-size: 12px;
          line-height: 40px;
          text-align: right;
          color: rgb(99, 99, 99);
        }
        .active {
          color: red;
        }
      }
    }
  }
}
</style>